package zuk.clipvietfun.plus;

import java.io.File;

import android.content.Context;

public class DirAndFile {
	public static boolean deleteDir(File path) {
		if( path.exists() ) {
			File[] files = path.listFiles();
			if (files == null) {
				return true;
			}
			for(int i=0; i<files.length; i++) {
				if(files[i].isDirectory()) {
					deleteDir(files[i]);
				}
				else {
					files[i].delete();
				}
			}
		}
		return( path.delete() );
	}


	public File makeFileHistory(File dirHistory){
		File fileHistory = new File(dirHistory, "history");
		try {
			if(!fileHistory.exists())
				fileHistory.createNewFile();
			return fileHistory;
		} catch (Exception e) {
		}
		return fileHistory;
	}
	
	public File makeDirHistory(Context context){
		File dirHistory = new File(context.getCacheDir()+"/LikeAndHistory");
		try {
			if(!dirHistory.exists())
				dirHistory.mkdirs();
			return dirHistory;
		} catch (Exception e) {
		}
		return dirHistory;
	}
	
	public File makeFileLike(File dirLike){
		File fileLike = new File(dirLike, "like");
		try {
			if(!fileLike.exists())
				fileLike.createNewFile();
			return fileLike;
		} catch (Exception e) {
		}
		return fileLike;
	}
	
	public File makeDirLike(Context context){
		File dirLike = new File(context.getCacheDir()+"/LikeAndHistory");
		try {
			if(!dirLike.exists())
				dirLike.mkdirs();
			return dirLike;
		} catch (Exception e) {
		}
		return dirLike;
	}
}

